package OpenID::Tester::Capabilities;
use strict;

# A capability document is a series of lines in
# a text/plain document, with capabilities matching
# [\w\-\.]+, with comments anywhere starting with '#'
# blank lines are okay.
sub new {
    my ($class, $cap_doc) = @_;
    my $self = bless {}, $class;
    foreach my $cap (split(/[\n\r]/, $cap_doc)) {
        $cap =~ s/\#.*//;
        $cap =~ s/^\s+//;
        $cap =~ s/\s$//;
        next unless $cap =~ /\S/;
        die "Bogus capability line: $cap" unless $cap =~ m!^[\w\-\.]+$!;
        $self->{$cap} = 1;
    }
    return $self;
}

sub has_cap {
    my ($self, $cap) = @_;
    return $self->{$cap};
}


1;
